rs2324 2.2.0
Loading...
Searching...
No Matches
rs2324.h
Go to the documentation of this file.
1/****************************************************************************
2** Copyright (C) 2020 MikroElektronika d.o.o.
3** Contact: https://www.mikroe.com/contact
4**
5** Permission is hereby granted, free of charge, to any person obtaining a copy
6** of this software and associated documentation files (the "Software"), to deal
7** in the Software without restriction, including without limitation the rights
8** to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9** copies of the Software, and to permit persons to whom the Software is
10** furnished to do so, subject to the following conditions:
11** The above copyright notice and this permission notice shall be
12** included in all copies or substantial portions of the Software.
13**
14** THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
15** EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
16** OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
17** IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
18** DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT
19** OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
20** USE OR OTHER DEALINGS IN THE SOFTWARE.
21****************************************************************************/
22
27
28#ifndef RS2324_H
29#define RS2324_H
30
31#ifdef __cplusplus
32extern "C"{
33#endif
34
39#ifdef PREINIT_SUPPORTED
40#include "preinit.h"
41#endif
42
43#ifdef MikroCCoreVersion
44 #if MikroCCoreVersion >= 1
45 #include "delays.h"
46 #endif
47#endif
48
49#include "drv_digital_out.h"
50#include "drv_digital_in.h"
51#include "drv_uart.h"
52
58
63
68
74#define RS2324_TX_DRV_BUFFER_SIZE 256
75#define RS2324_RX_DRV_BUFFER_SIZE 256
76 // rs2324_cmd
78
83
88
93#define RS2324_MAP_MIKROBUS( cfg, mikrobus ) \
94 cfg.tx_pin = MIKROBUS( mikrobus, MIKROBUS_TX ); \
95 cfg.rx_pin = MIKROBUS( mikrobus, MIKROBUS_RX ); \
96 cfg.cts = MIKROBUS( mikrobus, MIKROBUS_CS ); \
97 cfg.rts = MIKROBUS( mikrobus, MIKROBUS_INT );
98 // rs2324_map // rs2324
101
106typedef struct
107{
108 // Output pins
109 digital_out_t cts;
110
111 // Input pins
112 digital_in_t rts;
113
114 // Modules
115 uart_t uart;
116
117 // Buffers
120
121} rs2324_t;
122
127typedef struct
128{
129 // Communication gpio pins
130 pin_name_t rx_pin;
131 pin_name_t tx_pin;
132
133 // Additional gpio pins
134 pin_name_t cts;
135 pin_name_t rts;
136
137 // Static variable
138 uint32_t baud_rate;
140 uart_data_bits_t data_bit;
141 uart_parity_t parity_bit;
142 uart_stop_bits_t stop_bit;
143
145
150typedef enum
151{
154
156
162
173
187err_t rs2324_init ( rs2324_t *ctx, rs2324_cfg_t *cfg );
188
201err_t rs2324_generic_write ( rs2324_t *ctx, uint8_t *data_in, uint16_t len );
202
215err_t rs2324_generic_read ( rs2324_t *ctx, uint8_t *data_out, uint16_t len );
216
226void rs2324_set_cts_pin ( rs2324_t *ctx, uint8_t state );
227
237
238#ifdef __cplusplus
239}
240#endif
241#endif // RS2324_H
242 // rs2324
244
245// ------------------------------------------------------------------------ END
#define RS2324_TX_DRV_BUFFER_SIZE
RS232 4 driver buffer size.
Definition rs2324.h:74
#define RS2324_RX_DRV_BUFFER_SIZE
Definition rs2324.h:75
uint8_t rs2324_get_rts_pin(rs2324_t *ctx)
RS232 4 get RTS pin function.
void rs2324_set_cts_pin(rs2324_t *ctx, uint8_t state)
RS232 4 set CTS pin function.
err_t rs2324_generic_write(rs2324_t *ctx, uint8_t *data_in, uint16_t len)
RS232 4 data writing function.
err_t rs2324_generic_read(rs2324_t *ctx, uint8_t *data_out, uint16_t len)
RS232 4 data reading function.
void rs2324_cfg_setup(rs2324_cfg_t *cfg)
RS232 4 configuration object setup function.
err_t rs2324_init(rs2324_t *ctx, rs2324_cfg_t *cfg)
RS232 4 initialization function.
rs2324_return_value_t
RS232 4 Click return value data.
Definition rs2324.h:151
@ RS2324_ERROR
Definition rs2324.h:153
@ RS2324_OK
Definition rs2324.h:152
RS232 4 Click configuration object.
Definition rs2324.h:128
pin_name_t rts
Definition rs2324.h:135
uint32_t baud_rate
Definition rs2324.h:138
pin_name_t cts
Definition rs2324.h:134
bool uart_blocking
Definition rs2324.h:139
uart_data_bits_t data_bit
Definition rs2324.h:140
pin_name_t tx_pin
Definition rs2324.h:131
pin_name_t rx_pin
Definition rs2324.h:130
uart_stop_bits_t stop_bit
Definition rs2324.h:142
uart_parity_t parity_bit
Definition rs2324.h:141
RS232 4 Click context object.
Definition rs2324.h:107
uint8_t uart_tx_buffer[RS2324_TX_DRV_BUFFER_SIZE]
Definition rs2324.h:119
uart_t uart
Definition rs2324.h:115
uint8_t uart_rx_buffer[RS2324_RX_DRV_BUFFER_SIZE]
Definition rs2324.h:118
digital_in_t rts
Definition rs2324.h:112
digital_out_t cts
Definition rs2324.h:109